<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" >
        <el-form-item label="案件编号" prop="ajbh">
          <el-input
            v-model="queryParams.ajbh"
            placeholder="请输入案件编号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="被取保候审人(被行政拘留人)" prop="hsr">
          <el-input
            v-model="queryParams.hsr"
            placeholder="请输入被取保候审人(被行政拘留人)"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
        <el-form-item>
      <el-radio-group v-model="queryParams.hbshzt">  
      <el-radio label="1" @change="handleQuery">待审核</el-radio>
      <el-radio label="2" @change="handleQuery">已审核</el-radio>
      <el-radio label="4" @change="handleQuery">已办结</el-radio>
      </el-radio-group>
    </el-form-item>
      </el-form>
  
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['system/bzjtable/export']" >导出</el-button>
        </el-col>
        <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-edit" size="mini" :disabled="single" @click="doubleclick">划拨</el-button>
      </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
  
      <el-table v-loading="loading" :data="transferList" @selection-change="handleSelectionChange"  @current-change="tableCurrentChange" @row-dblclick="doubleclick">
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column label="Key" align="center" prop="xh" />
        <el-table-column label="案件编号" align="center" prop="ajbh" />
        <el-table-column label="案件名称" align="center" prop="ajmc" />
        <el-table-column label="收取法律文书号" align="center" prop="sqwsh" />
        <el-table-column label="被取保候审人(被行政拘留人)" align="center" prop="hsr" />
        <el-table-column label="划拨法律文书号" align="center" prop="hbwsh" />
        <el-table-column label="划拨单位名称" align="center" prop="hbdw" />
        <el-table-column label="执行法院账户名称" align="center" prop="hb_dgyhzh" />
        <el-table-column label="执行法院开户行" align="center" prop="hb_khh" />
        <el-table-column label="执行法院账号" align="center" prop="hb_yhzh" />
        <el-table-column label="取保候审保证金" align="center" prop="sqje" />
        <el-table-column label="划拨金额" align="center" prop="hbje" />
        <el-table-column label="人员类别" align="center" prop="xjr" />
        <el-table-column label="性别" align="center" prop="xb" />
        <el-table-column label="出生日期" align="center" prop="csrq" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.csrq, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column label="住址" align="center" prop="zz" /> -->
        <el-table-column label="户籍地址" align="center" prop="hjdz" />
        <el-table-column label="单位及职务" align="center" prop="dwzw" />
        <el-table-column label="联系电话" align="center" prop="lxdh" />
        <el-table-column label="委托交款人代" align="center" prop="jkr" />
        <el-table-column label="收银行编号" align="center" prop="dsyhbh" />
        <el-table-column label="缴款时间" align="center" prop="jnsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.jnsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="交纳银行卡号" align="center" prop="jnkh" />
        <el-table-column label="批准人" align="center" prop="pzr" />
        <el-table-column label="取保候审批准时间" align="center" prop="pzsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.pzsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="办案人" align="center" prop="bar" />
        <el-table-column label="办案人所在单位编号" align="center" prop="dwbh" />
        <el-table-column label="办案单位" align="center" prop="badw" />
        <el-table-column label="收取日期" align="center" prop="sqrq" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.sqrq, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="填报时间" align="center" prop="sqtfsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.sqtfsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="单据状态" align="center" prop="djzt" />
        <el-table-column label="单据时间" align="center" prop="djsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.djsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="划拨操作员" align="center" prop="hbczy" />
        <el-table-column label="提交日期" align="center" prop="hbsj" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.hbsj, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="划拨单位联系人电话" align="center" prop="hblxdh" />
      </el-table>
      

      <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 双击弹窗 -->
    <el-dialog :title="tit" :visible.sync="open" width="80%" @closed="gb">
  <el-form ref="form" :inline="true" :model="form" :rules="ruless" label-width="auto" :hide-required-asterisk="true"  class="creation demo-form-inline">
          <el-row :gutter="20">
            <el-col :span="24">
            <el-divider content-position="center">案件信息</el-divider>
          </el-col>
          <el-col :span="8">
          <el-form-item label="案件编号" prop="ajbh">
            <el-input v-model="form.ajbh" :disabled="true" style="width: 115%;"/>
          </el-form-item>
          </el-col>
          <el-col :span="8">
          <el-form-item label="案件名称" prop="ajmc">
            <el-input v-model="form.ajmc"  :disabled="true" style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="案件性质" prop="ajxz">
            <el-input v-model="form.ajxz" :disabled="true" style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="收取法律文书号" prop="sqwsh">
            <el-input v-model="form.sqwsh"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案人" prop="bar">
            <el-input v-model="form.bar"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案单位" prop="badw">
            <el-input v-model="form.badw"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="被取保候审(被行政拘留)人" prop="hsr">
            <el-input v-model="form.hsr"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="人员类别" prop="xjr">
            <el-input v-model="form.xjr"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="性别" prop="xb">
            <el-input v-model="form.xb"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="身份证号" prop="sfzh">
            <el-input v-model="form.sfzh"  :disabled="true" style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="户籍地址" prop="hjdz">
            <el-input v-model="form.hjdz"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="出生日期" prop="csrq">
            <el-date-picker clearable
              v-model="form.csrq"
              type="date"
              value-format="yyyy-MM-dd"
              style="width: 100%;"
              :disabled="true">
            </el-date-picker>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="联系电话" prop="lxdh">
            <el-input v-model="form.lxdh"  :disabled="true" style="width: 115%;"/>
          </el-form-item>
        </el-col>
        <el-col :span="8" >
        <el-form-item label="委托人">
          <el-input v-model="form.jkr" placeholder="请输入委托人" disabled style="width: 115%;"/>
        </el-form-item>
      </el-col>
        <el-col :span="8" >
        <el-form-item label="委托人身份证号">
          <el-input v-model="form.jkrsfz" placeholder="请输入委托人身份证号" disabled style="width: 115%;"/>
        </el-form-item>
      </el-col>
        <el-col :span="24">
            <el-divider content-position="center">划拨信息</el-divider>
          </el-col>
          <el-col :span="8">
          <el-form-item label="执行法院账户名称" prop="hb_dgyhzh">
          <el-input v-model="form.hb_dgyhzh" :disabled="true"  style="width: 115%;"/>
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="执行法院开户行" prop="hb_khh">
          <el-input v-model="form.hb_khh" :disabled="true"  style="width: 115%;" />
        </el-form-item>
          </el-col>
          <el-col :span="8">
        <el-form-item label="执行法院账号" prop="hb_yhzh">
          <el-input v-model="form.hb_yhzh" :disabled="true"  style="width: 115%;"/>
        </el-form-item>
          </el-col>
          <el-col :span="8">
          <el-form-item label="保证金金额" prop="sqje">
            <el-input v-model="form.sqje"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="没收金额" prop="msje">
            <el-input v-model="form.msje"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="退还金额" prop="thje">
            <el-input v-model="form.thje"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="划拨金额" prop="hbje">
            <el-input v-model="form.hbje"  :disabled="true"  style="width: 115%;"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案人" prop="hbczy">
            <el-input v-model="form.hbczy" style="width: 115%;":disabled="true"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
          <el-form-item label="办案人联系电话" prop="hblxdh">
            <el-input v-model="form.hbczy" style="width: 115%;":disabled="true"/>
          </el-form-item>
        </el-col>
          <el-col :span="8">
            <el-form-item label="划拨填报时间" prop="hbsj">
            <el-date-picker clearable
              v-model="form.hbsj"
              type="date"
              value-format="yyyy-MM-dd"
              style="width: 100%;"
              placeholder="请选择划拨填报时间"
              :disabled="true">
            </el-date-picker>
          </el-form-item>
        </el-col>

          </el-row>
        </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="success" plain icon="el-icon-success"  :disabled="!form.ajmc" @click="handleSuccess" >通过</el-button>
        <el-button type="danger" plain icon="el-icon-error"  :disabled="!form.ajmc" @click="handleBack" >退回</el-button>
        <el-button type="primary" plain icon="el-icon-upload" :disabled="!form.xh" @click="handleYwbj" >业务办结</el-button>
        <el-button type="warning" plain icon="el-icon-s-promotion" :disabled="!form.ajmc" @click="handleBackNotice" >发送退款通知</el-button>
        <el-button type="warning" @click="handleckfj(form)" >查看附件</el-button>
        <el-button type="primary" @click="handlecklc(form)" >查看流程</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>


    <el-dialog :title="title" :visible.sync="dialogShenHe">  
            <div style="display: flex;align-items: stretch;justify-content: space-evenly;flex-direction: column;height: 220px;">
  
        <div style="display: flex;align-items: center;justify-content: center;">
          <div>审批意见:</div>
          <el-input v-model="spyj" style="width: 85%;" :rows="5" type="textarea"></el-input>
        </div>
        <div style="display: flex;align-items: center;justify-content: center;">
          <div  style="margin-left: 11px;">审批人:</div>
          <el-input v-model="spr" style="width: 40%;"  type="text"></el-input>
          <div style="margin-left: 11px;">职务:</div>
          <el-select v-model="sprzw" style="width: 40%;" :rows="5" type="text"  clearable  placeholder="请选择职务">
            <el-option
          v-for="item in dict.type.sys_sprzw"
          :key="item.value"
          :label="item.label"
          :value="item.label"
        />
            </el-select>
        </div>
            </div>
          <div style="display: flex;align-items: center;justify-content: center;">
          <Upload v-model="form.files" :data="{}" acceptTip="*仅图片、PDF类型文件可在线预览"
            multiple></Upload>        
          </div>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="dialogShenHe=false">取 消</el-button>
        </div>
      </el-dialog>



      <el-dialog title="查看流程" :visible.sync="dialogFlowerTable"  @closed="dialogFlowerTable=false">
        <el-table height="600" border :data="flowerList" :header-cell-style="{ backgroundColor: 'rgb(237 237 237)'}">
          <el-table-column label="案件类别" prop="lb" hidden/>
          <el-table-column label="审批环节" prop="ajlx" />
          <el-table-column label="审批意见" prop="spyj" width="200"/>
          <el-table-column label="审批人" prop="spr" />
          <el-table-column label="审批人职务" prop="sprzw" width="100"/>
          <el-table-column label="审批单位" prop="spdw" width="200"/>
          <el-table-column label="审批时间" prop="spsj" width="180"/>
        </el-table>
      </el-dialog>
      <el-dialog title="查看附件" :visible.sync="dialogFormVisible">
        <el-table height="600" border :data="fileList" :header-cell-style="{ backgroundColor: 'rgb(237 237 237)'}">
          <el-table-column label="文件名称" prop="fjmc" />
          <el-table-column label="环节" prop="lb" />
          <el-table-column label="文件类型" prop="wjlx" />
          <el-table-column fixed="right" label="操作" width="200">
            <template slot-scope="scope">
              <el-button type="success" plain size="mini" @click="handlexzfj(scope.row)" :disabled="!scope.row.wjdz" >下载附件</el-button>
              <el-button type="success" plain size="mini" @click="yul(scope.row)" :disabled="!(scope.row.wjdz.split('.')[1] == 'png' || scope.row.wjdz.split('.')[1] == 'jpg' || scope.row.wjdz.split('.')[1] == 'jpeg')" >预览</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import { Transfer, getTransfer, delTransfer, addTransfer, updateTransfer,hbsh ,getFjList,getListByXhDetail} from "@/api/system/bzjtable";
  import selectMultiple from '@/views/collect/addSecurity/selectMultiple'
  import Print from '@/utils/print.js'
  import Upload from './DzpjUpload'
  import { tansParams, blobValidate } from "@/utils/ruoyi";
  import XLSX from 'xlsx';//引入
  import { saveAs } from 'file-saver'
  import pdf from "vue-pdf"
  
  export default {
    name: "Transfertable",
    dicts: ['sys_sprzw'],
    data() {
        let amount = (rule, value, callback) => {
      if (value) {
        if (!/^(0|[1-9]\d*)(\s|$|\.\d{1,2}\b)/.test(value)) return callback(new Error('请输入非负数、最多含两位小数'))
        // if (value <= 0) return callback(new Error('划拨金额应大于0'))
        if (value > 999999999999.99) return callback(new Error('执行金额不能超过999999999999.99'))
      }
     else {
        return callback(new Error('请输入执行金额'))
      }
      callback()
    }
    let dialogVisible = (rule, val, callback) => {
      if (!val) callback(new Error('请输入手机号'))
      let exp = new RegExp(/^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/)
      if (!exp.test(val)) {
        return callback(new Error('手机号格式不对'))
      }
      return callback()
    }
    let dialogVisibleFile = (rule, value, callback) => {
      console.log(value?.length, ';');
      if (rule.required) {
        if (value?.length) {
          callback()
        } else {
          return callback(new Error('请选择文件'))
        }
      }
      callback()
    }
      return {
        flowerList:[],
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // transfer表格数据
        transferList: [],
        fileList: [],
        clickedRowData: null,
        // 弹出层标题
        title: "",
        spyj:'',
        spr:'',
        sprzw:'',
        pdfUrl: '',
        // formInfo: {},
        wjdz: '',
        // 是否显示弹出层
        open: false,
        dialogShenHe:false,
        dialogFormVisible:false,
        dialogFlowerTable:false,
        pdfs: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          ajbh: null,
          ajmc: null,
          sqwsh: null,
          hsr: null,
          xjr: null,
          xb: null,
          csrq: null,
          zz: null,
          hjdz: null,
          dwzw: null,
          lxdh: null,
          sfzh: null,
          ajxz: null,
          sqje: null,
          sqfs: null,
          sqzt: '1',
          jkr: null,
          jkrsfz: null,
          dsyhbh: null,
          jnsj: null,
          jnkh: null,
          pzr: null,
          pzsj: null,
          bar: null,
          dwbh: null,
          badw: null,
          sqrq: null,
          sqtfsj: null,
          sqtfr: null,
          msje: null,
          mszt: null,
          msyy: null,
          mswsh: null,
          mspzr: null,
          mspzsj: null,
          mstfr: null,
          msrq: null,
          mstfsj: null,
          msshzt: null,
          mskhzt: null,
          mskhsj: null,
          mskhczr: null,
          thje: null,
          thfs: null,
          thzt: null,
          thrq: null,
          thwsh: null,
          thpzr: null,
          thtfsj: null,
          thshzt: null,
          thshr: null,
          thshsj: null,
          thxm: null,
          thzh: null,
          thkhh: null,
          djzt: null,
          sqdyzt: null,
          djsj: null,
          sqkpzt: null,
          thkpzt: null,
          hbwsh: null,
          hbdw: null,
          hbje: null,
          hbry: null,
          hbrq: null,
          hblxdh: null,
          hbsj: null,
          hbczy: null,
          thtfr: null,
          HBYJ : null,
          hbzt:'0',
          hbshzt:'1'
        },
        // 表单参数
        form: {
        xh : null,
        ajbh : null,  
        ajmc : null,
        hsr : null,
        xjr : null,
        hbje :null,
        hbrq : null,
        hbwsh : null,
        HBYJ : null,
        hbry : null,
        hblxdh : null,
        hbshzt : null,
        hbczy:null,
        hbsj:null,
        badw : null,
        hbdw : null,
        pjfy : null,
        hb_dgyhzh : null,
        },
        currentIndex: '',
        // 表单校验
        ruless: {
        hbdw: [{ required: true, trigger: 'change',message: '请输入被移送单位' }],
        pjfy: [{ required: true, trigger: 'change',message: '请输入执行法院名称' }],
        hbwsh: [{ required: true, trigger: 'change',message: '请输入法院协助执行通知书文号' }],
        HBYJ: [{ required: true, trigger: 'change',message: '请输入移交原因' }],
        hb_dgyhzh: [{ required: true, trigger: 'change',message: '请输入执行法院账户名称' }],
        hb_yhzh: [{ required: true, trigger: 'change',message: '请输入执行法院账号' }],
        hb_khh: [{ required: true, trigger: 'change',message: '请输入执行法院开户行' }],
        hbrq: [{ required: true, trigger: 'change',message: '请选择执行日期' }],
        hbry: [{ required: true, trigger: 'change',message: '请输入办案人' }],

        hbje: [{ required: true, validator: amount, trigger: 'change' }],
        hblxdh: [{ required: true, validator: dialogVisible, trigger: 'change' }],
        files: [{ required: true, validator: dialogVisibleFile, trigger: 'change' }]
        }
      };
    },
    components: {
    selectMultiple,
    Upload,
    pdf
  },
    created() {
      this.getList();
    },
    methods: {
      /** 查询transfer列表 */
      getList() {
        this.loading = true;
        Transfer(this.queryParams).then(response => {
          this.transferList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
       },
       tableCurrentChange(row) {
      this.form = row
      this.currentIndex = row?.pIndex
    },
    handleSuccess() {
        const CANNOT_COMPLETE =this.form.hbshzt
        if (CANNOT_COMPLETE === "2") {  
          return this.$message.error('当前业务不可审核')
        }else{
        this.title = '审核通过'
        this.dialogShenHe = true
        }
        
      },
      submitForm() { 
        if(!this.spyj){
          return this.$message.error('请输入审批意见')
        }
        if(!this.spr){
          return this.$message.error('请输入审批人')
        }
        if(!this.sprzw){
          return this.$message.error('请选择审批人职务')
        }
        this.form.spyj = this.spyj
        this.form.spr = this.spr
        this.form.sprzw = this.sprzw
        this.form.hbshzt = this.title == "审核通过"?2:3
        hbsh(this.form).then(() => {
            this.$modal.msgSuccess(this.title == "审核通过"?"审核通过":'审核退回')
            this.dialogShenHe = false
            this.open=false
            this.getList()
          })
      },
      yul(val) {
        downLoadFile({ wjdz: val.wjdz }).then(async (data) => {
          // if (this.wjdz && this.wjdz.split('.')[1] == 'png' || this.wjdz &&this.wjdz.split('.')[1] == 'jpg' || this.wjdz.split('.')[1] == 'jpeg') {
            const url = window.URL.createObjectURL(data);
            this.pdfUrl = url;//直接用iframe标签
            this.pdfs = true
          // }
        })
      },
      handleckfj(row) {
        this.dialogFormVisible = true
        getFjList({ xh: row.xh }).then((res) => {
          this.fileList = res.rows
          // this.fileList.forEach((item) => {
          //   item.typeName = this.dict.type.sys_type.filter((e)=>item.wjlx==e.value)[0].label
          // })
        })
  
      },
      handlecklc(row) {
        this.dialogFlowerTable = true
        getListByXhDetail(row.xh,1).then((res) => {
          this.flowerList = res.rows
        })
      },
      handlexzfj(val) {
        // this.download('/confiscate/forfeitureOfDeposit/downLoadFile', { wjdz: this.form.wjdz }, `role_${new Date().getTime()}.png`)
        downLoadFile({ wjdz: val.wjdz }).then(async (data) => {
          this.$modal.msgSuccess("下载成功");
          const url = window.URL.createObjectURL(data);
          this.pdfUrl = url;//直接用iframe标签
          const isBlob = blobValidate(data);
          if (val.wjdz && val.wjdz.split('.')[1] == 'png' || val.wjdz &&val.wjdz.split('.')[1] == 'jpg' || val.wjdz &&val.wjdz.split('.')[1] == 'jpeg') {
            if (isBlob) {
              const blob = new Blob([data])
              saveAs(blob, `role_${new Date().getTime()}.png`)
            } else {
              const resText = await data.text();
              const rspObj = JSON.parse(resText);
              const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
              Message.error(errMsg);
            }
          } else if (val.wjdz &&val.wjdz.split('.')[1] == 'pdf') {
            // let pdfUrl = window.URL.createObjectURL(new Blob([data], { type: "application/pdf" }));
            // window.open(pdfUrl)
            let blob = new Blob([data], { type: 'application/pdf' });
            let downloadElement = document.createElement("a");
            let href = window.URL.createObjectURL(blob); //创建下载的链接
            downloadElement.href = href;
            downloadElement.download = `pdf下载`    //下载后的文件名，根据需求定义
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href); //释放掉blob对象
          } else {
            const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' }) // response就是接口返回的文件流
            const objectUrl = URL.createObjectURL(blob)
            const a = document.createElement('a') // 创建a标签
            a.href = objectUrl
            a.download = 'excel下载' // 自定义文件名
            a.click() // 下载文件
            window.URL.revokeObjectURL(objectUrl) // 释放内存
            // link.remove()
          }
          this.dialogFormVisible = false
        })
      },
      handleBack() {
        const CANNOT_COMPLETE =this.form.hbshzt
        if (CANNOT_COMPLETE === "2") {  
          return this.$message.error('当前业务不可退回')
        }else{
        this.title = '审核退回'
        this.dialogShenHe = true
        }
      },
        /**双击操作 */
        doubleclick(row){
        this.form = row;
        this.tit = "划拨";
        this.open = true;
        },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      gb() {
      this.getList();
    },
      // 表单重置
      reset() {
        this.form = {
          xh: null,
          ajbh: null,
          ajmc: null,
          sqwsh: null,
          hsr: null,
          xjr: null,
          xb: null,
          csrq: null,
          zz: null,
          hjdz: null,
          dwzw: null,
          lxdh: null,
          sfzh: null,
          ajxz: null,
          sqje: null,
          sqfs: null,
          sqzt: 1,
          jkr: null,
          jkrsfz: null,
          dsyhbh: null,
          jnsj: null,
          jnkh: null,
          pzr: null,
          pzsj: null,
          bar: null,
          dwbh: null,
          badw: null,
          sqrq: null,
          sqtfsj: null,
          sqtfr: null,
          msje: null,
          mszt: null,
          msyy: null,
          mswsh: null,
          mspzr: null,
          mspzsj: null,
          mstfr: null,
          msrq: null,
          mstfsj: null,
          msshzt: null,
          mskhzt: null,
          mskhsj: null,
          mskhczr: null,
          thje: null,
          thfs: null,
          thzt: null,
          thrq: null,
          thwsh: null,
          thpzr: null,
          thtfsj: null,
          thshzt: null,
          thshr: null,
          thshsj: null,
          thxm: null,
          thzh: null,
          thkhh: null,
          djzt: null,
          sqdyzt: null,
          djsj: null,
          sqkpzt: null,
          thkpzt: null,
          hbwsh: null,
          hbdw: null,
          hbje: null,
          hbry: null,
          hbrq: null,
          hblxdh: null,
          hbsj: null,
          hbczy: null,
          thtfr: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      // // 多选框选中数据
      handleSelectionChange(selection) {
        if (selection.length > 0) {  
          // 假设我们只关心第一行数据  
          const selectedRow = selection[0];  
            
          // 填充 form 对象中对应的字段  
          this.form.xh = selectedRow.xh;  
          this.form.ajbh = selectedRow.ajbh;  
          this.form.ajmc = selectedRow.ajmc;  
          this.form.hsr = selectedRow.hsr;  
          this.form.xjr = selectedRow.xjr; 
          this.form.hbdw = selectedRow.hbdw;  
          this.form.badw = selectedRow.badw;  
          this.form.hbwsh = selectedRow.hbwsh;  
          this.form.HBYJ = selectedRow.HBYJ;  
          this.form.hbje = selectedRow.hbje;  
          this.form.hbrq = selectedRow.hbrq;  
          this.form.hbry = selectedRow.hbry;  
          this.form.hblxdh = selectedRow.hblxdh;
          // 打开对话框  
          // this.open = true;  
          // debugger
          this.ids = selection.map(item => item.xh)
          this.single = selection.length !== 1
          this.multiple = !selection.length
        } else {  
          // 如果没有选中任何行清空form对象
          this.reset(); // 假设你有一个方法来重置 form 对象  
        }  
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.queryParams.hsr = null
        this.queryParams.ajbh = null
        this.queryParams.sqzt = '1'
        this.queryParams.hbzt = '0'
        this.queryParams.hbshzt = '1'
        this.resetForm("queryForm");
        this.handleQuery();
      },

      /** 导出按钮操作 */
      handleExport() {
        this.download('system/bzjtable/export', {
          ...this.queryParams
        }, `transfer_${new Date().getTime()}.xlsx`)
      }
    }
  };
  </script>
  